package com.csce.domain.entity.score;

import com.doudou.core.container.ListUtil;
import com.doudou.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.osce.common.annotation.Excel;
import com.osce.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 考试对象 score_ex_exam
 *
 * @author zzx
 * @since 2023-09-05
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
@EqualsAndHashCode(callSuper = true)
public class ScoreExExam extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 名称
     */
    @Excel(name = "名称")
    @ApiModelProperty("名称")
    private String name;

    /**
     * 考试开始日期
     */
    @Excel(name = "考试开始日期")
    @ApiModelProperty("考试开始日期")
    @JsonFormat(pattern = DateUtil.yyyyMMdd)
    private Date exStartDate;

    /**
     * 考试结束日期
     */
    @Excel(name = "考试结束日期")
    @ApiModelProperty("考试结束日期")
    @JsonFormat(pattern = DateUtil.yyyyMMdd)
    private Date exEndDate;

    /**
     * 最后支持修改时间
     */
    //@Excel(name = "最后支持修改时间")
    @ApiModelProperty("最后支持修改时间")
    @JsonFormat(pattern = DateUtil.yyyyMMdd_HHmm)
    private Date lastTime;

    /**
     * 最大学生数
     */
    @Excel(name = "最大学生数")
    @ApiModelProperty("最大学生数")
    private Integer maxStudent;

    /**
     * 现场考官权重
     */
    @Excel(name = "现场考官权重")
    @ApiModelProperty("现场考官权重")
    private Integer sceneExaminerWi;

    /**
     * 中控考官权重
     */
    @Excel(name = "中控考官权重")
    @ApiModelProperty("中控考官权重")
    private Integer centerExaminerWi;

    /**
     * 远程考官权重
     */
    @Excel(name = "远程考官权重")
    @ApiModelProperty("远程考官权重")
    private Integer sshExaminerWi;

    /**
     * 考试间隔时间
     */
    @Excel(name = "考试间隔时间")
    @ApiModelProperty("考试间隔时间")
    private Integer examIntervalTime;

    /**
     * 排站规则
     */
    @Excel(name = "排站规则")
    @ApiModelProperty("排站规则")
    private String allotPlaceRule;

    /**
     * 必过技能
     */
    @Excel(name = "必过技能")
    @ApiModelProperty("必过技能")
    private String mustSkill;

    /**
     * 是否展示学员姓名 1展示 2不展示
     */
    @Excel(name = "是否展示学员姓名")
    @ApiModelProperty("是否展示学员姓名")
    private String nameShow;

    /**
     * 状态
     */
    @Excel(name = "排站状态")
    @ApiModelProperty("排站状态")
    private Integer allotStatus;

    /**
     * 状态
     */
    @Excel(name = "状态")
    @ApiModelProperty("状态")
    private Integer status;

    /**
     * 预留字段1
     */
    @Excel(name = "预留字段1")
    @ApiModelProperty("预留字段1")
    private String reservedOne;

    /**
     * 预留字段2
     */
    @Excel(name = "预留字段2")
    @ApiModelProperty("预留字段2")
    private String reservedTwo;

    private List<ScoreExExamTime> exExamTimeList;
    private List<ScoreExExamPlace> exExamPlaceList;
    private Integer scoreExExamPlaceCount;


    public String startTimeStr() {
        return DateUtil.formatDate(this.exStartDate);
    }

    public String endTimeStr() {
        return DateUtil.formatDate(this.exEndDate);
    }

    public String dateRangeStr() {
        return startTimeStr() + "-" + endTimeStr();
    }

    /**
     * 将时间段以id做key返回map
     */
    public Map<Long, ScoreExExamTime> getTimeMap() {
        return new HashMap<Long, ScoreExExamTime>() {{
            if (ListUtil.isNotEmpty(exExamTimeList)) {
                for (ScoreExExamTime time : exExamTimeList) {
                    put(time.getId(), time);
                }
            }
        }};
    }

    /**
     * 将场地以id做key返回map
     */
    public Map<Long, ScoreExExamPlace> getPlaceMap() {
        return new HashMap<Long, ScoreExExamPlace>() {{
            if (ListUtil.isNotEmpty(exExamPlaceList)) {
                for (ScoreExExamPlace place : exExamPlaceList) {
                    put(place.getId(), place);
                }
            }
        }};
    }


}
